package com.yenlien.traceyun.control.dao;

import com.yenlien.traceyun.control.entity.Position;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author jialong
 * @date 2021/05/19
 * @description: 仓位数据层
 **/
public interface PositionDao extends BaseJpaDao<Position> {

    @Query(value = "SELECT * FROM position WHERE `name` = ?1 AND store_id IN (?2)", nativeQuery = true)
    List<Position> findByNameAndStoreIds(String name, List<Long> storeIds);

    @Query(value = "SELECT * FROM position WHERE store_id IN (?1)", nativeQuery = true)
    List<Position> findByStoreIds(List<Long> storeIds);

    @Query(value = "SELECT * FROM position WHERE store_id = ?1", nativeQuery = true)
    List<Position> findByStoreId(Long storeId);

    @Query(value = "SELECT * FROM position WHERE company_id = ?1", nativeQuery = true)
    List<Position> findByCompanyId(String companyId);

}
